<center>    
    <script src="<?php echo APP_DOMAIN . '/public/js/datepicker/mootools-core.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo APP_DOMAIN . '/public/js/datepicker/mootools-more.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo APP_DOMAIN . '/public/js/datepicker/Picker.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo APP_DOMAIN . '/public/js/datepicker/Picker.Attach.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo APP_DOMAIN . '/public/js/datepicker/Picker.Date.js'; ?>" type="text/javascript"></script>  
    <link href="<?php echo APP_DOMAIN . '/public/css/datepicker_vista.css'; ?>" rel="stylesheet" type="text/css" />

    <?php
    $pagename = $_GET['pagename'];
    $pageid = $_GET['pageid'];
//$articleid = $_GET['articleid'];
//
//if($articleid > 0 )
//{
//	echo $articleid;
//	echo $this->articledetail->tieu_de;
//	
//	
//}
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <form method="post" name="f1" action="<?php echo APP_DOMAIN ?>/admin/thisinh/save" enctype="multipart/form-data">
        <center>
            <h1><?php echo $pagename ?></h1>
        </center>
        <div class="nut_page">
<!--            <input type="submit" name="submit" value="Lưu">-->
            <a href="javascript:void(0);" onclick="postInfo();">Lưu</a>
        </div>


        <div>
            <div class='page_cat'>
                <div class='page_title' >
                    Mã facebook *
                </div>

                <div class='page_input'>			
                    <input class="input500" type="text" name="id_fb_thi_sinh" size="50px" id="id_fb_thi_sinh" value="<?php echo $this->id_fb_thi_sinh ?>">
                </div>
            </div>


            <div class='page_cat'>
                <div class='page_title' >
                    Tên thí sinh *
                </div>

                <div class='page_input'>			
                    <input class="input500" type="text" name="ten_thi_sinh" size="50px" id="ten_thi_sinh" value="<?php echo $this->ten_thi_sinh ?>">
                </div>
            </div>

            <div class='page_cat'>
                <div class='page_title' >
                    Email *
                </div>

                <div class='page_input'>			
                    <input class="input500" type="text" name="email" size="50px" id="email" value="<?php echo $this->email ?>">
                </div>
            </div>


            <div class='page_cat'>
                <div class='page_title' >
                    Số điện thoại
                </div>

                <div class='page_input'>			
                    <input class="input500" type="text" name="so_dien_thoai" size="50px" id="so_dien_thoai" value="<?php echo $this->so_dien_thoai ?>">
                </div>
            </div>

            <div class='page_cat'>
                <div class='page_title' >
                    Ngày sinh
                </div>

                <div class='page_input'>		
                    <?php
                    if ($this->ngay_sinh > 0) {
                        $date = date('m/d/Y', $this->ngay_sinh);
                    } else {
                        $date = '';
                    }
                    ?>
                    <input class="input500" type="text" name="ngay_sinh" size="50px" id="ngay_sinh" value="<?php echo $date; ?>"> (m/d/y)
                </div>
            </div>


            <div class='page_cat'>
                <div class='page_title' >
                    Ẩn/Hiện
                </div>

                <div class='page_input'>			
                    <input type="checkbox" <?php if ($this->an_hien == 1) echo " checked='checked' " ?>  value="1" name="an_hien">  ( Check vào là hiển thị )
                </div>
            </div>



            <div class='page_cat'>
                <div class='page_title' >
                    Giới tính
                </div>

                <div class='page_input'>	
                    <?php
                    $checkedvip0 = "checked='checked'";
                    $checkedvip1 = "";
                    if ($this->gioi_tinh == 1) {
                        $checkedvip1 = "checked='checked'";
                        $checkedvip0 = "checked=''";
                    }
                    ?>		
                    Nữ	<input type="radio" <?php echo $checkedvip0 ?>  value="0" name="gioi_tinh" />
                    Nam <input type="radio" <?php echo $checkedvip1 ?> value="1" name="gioi_tinh" />
                </div>

            </div>

            <div class='page_cat'>
                <div class='page_title' >
                    Số chứng minh thư
                </div>

                <div class='page_input'>			
                    <input class="input500" type="text" name="cmnd" size="50px" id="cmnd" value="<?php echo $this->cmnd ?>">
                </div>

            </div>

            <div class='page_cat'>
                <div class='page_title' >
                    Hình dự thi *
                </div>

                <div class='page_input'>			
<!--                    <input class="input500" type="file" name="hinh_du_thi" size="37px" id="hinh_du_thi" value="<?php echo $this->hinh_du_thi ?>">                    -->
                    <textarea id="hinh_du_thi" name="hinh_du_thi" style="display: none;"><?php echo $this->hinh_du_thi; ?></textarea>
                    <a href="javascript:void(0);" onclick="showUpload();">Đăng ảnh</a>                    
                </div>
            </div>
            <p id="image_content">                        
            </p>

            <div class='page_cat'>
                <div class='page_title' style=" margin-top: 16px;">
                    Giới thiệu của thí sinh
                </div>

                <div class='page_input'>
                    <textarea class="textarea700" name="gioi_thieu" id="gioi_thieu" style="text-align:left;height: 55px; width: 500px; resize: none; border: medium 1;"><?php echo $this->gioi_thieu ?></textarea>
                    <script type="text/javascript" language="javascript">
                        CKEDITOR.replace('gioi_thieu', {
                            toolbar: 'Content',
                            width: 520,
                            height: 200
                        });
                    </script>
                </div>

            </div>

            <div class='page_cat'>
                <div class='page_title' style=" margin-top: 16px;">
                   Nội dung ảnh dự thi
                </div>

                <div class='page_input'>
                    <textarea class="textarea700" name="mo_ta_bai_thi" id="mo_ta_bai_thi" style="text-align:left;height: 55px; width: 500px; resize: none; border: medium 1;"><?php echo $this->mo_ta_bai_thi ?></textarea>
                    <script type="text/javascript" language="javascript">
                        CKEDITOR.replace('mo_ta_bai_thi', {
                            toolbar: 'Content',
                            width: 520,
                            height: 200
                        });
                    </script>
                </div>

            </div>


        </div>
        <input type='hidden' value='<?php echo $pageid ?>' name='id_fb_page' />
         <input type='hidden' value='<?php echo $pagename ?>' name='pagename' />
        <input type='hidden' value='<?php echo $this->id_thi_sinh ?>' name='id_thi_sinh' />
    </form>

    <script>   
        var count = 0;
        //Change these values to style your modal popup
        var align = 'center';									//Valid values; left, right, center
        var ptop = 400; 											//Use an integer (in pixels)
        var width = 0; 										//Use an integer (in pixels)
        var padding = 10;										//Use an integer (in pixels)
        var backgroundColor = '#FFFFFF'; 						//Use any hex code
        var source = 'asdasda'; 								//Refer to any page on your server, external pages are not valid e.g. http://www.google.co.uk
        var borderColor = '#333333'; 							//Use any hex code
        var borderWeight = 4; 									//Use an integer (in pixels)
        var borderRadius = 5; 									//Use an integer (in pixels)
        var fadeOutTime = 300; 									//Use any integer, 0 = no fade
        var disableColor = '#666666'; 							//Use any hex code
        var disableOpacity = 40; 								//Valid range 0-100
        var loadingImage = 'lib/release-0.0.1/loading.gif';		//Use relative path from this page

        source = '<table style="text-align: center; width: 400px;"><tr><td>';
        source += '<form id="file_upload_form" method="post" enctype="multipart/form-data" action="<?php echo APP_DOMAIN . "/manage/upload"; ?>">';
        source+="<p><span id='msg'></span>";
        source += "<input name='data_src' id='data_src' size='27' type='file' />";
        source += "<span><a href='javascript:void(0);' onclick='processUpload();'>Đăng ảnh</a></span>";
        source +="<input type='hidden' name='action'  value='10' />";
        source +="<input type='hidden' name='callback'  value='uploadComplete' />";
        source +="<iframe id='upload_target' name='upload_target' src='' style='width:0;height:0;border:0px solid #fff;'></iframe>";
        source +="</p></form></td></tr></table>";
    
        var source2 = '<table style="text-align: center; width: 400px;"><tr><td>';
        source2 +="[content]";
        source2 +="</td></tr></table>";
        //This method initialises the modal popup
    		
        function showUpload(){
            modalPopup(align, ptop, width, padding, disableColor, disableOpacity, backgroundColor, borderColor, borderWeight, borderRadius, fadeOutTime, source, loadingImage);
        }        
        
        function processUpload(){
            if(count<<?php echo MAX_IMAGE; ?>){
                $("#msg").html("Đang xử lý ...");
                document.getElementById('file_upload_form').target = 'upload_target'; //'upload_target' is the name of the iframe                              
                document.getElementById('file_upload_form').submit();
            }else{
                $("#msg").html("Số hình vượt quá số lượng quy định");
            }           
            return false;
        }
    
        function uploadComplete(data) {        
            if(data.errorCode >=0){   
                var html = $("#hinh_du_thi").val();
                if($("#hinh_du_thi").val()!=''){
                    html +=';';                
                }
                html+=data.data;
                var link = '<?php echo APP_DOMAIN; ?>' + '/public/images/'+data.data;
                var img = "<img src='"+link+"' height='100px' style='margin: 2px; border: 1px solid;' />"
                $('#image_content').append(img);
                $("#hinh_du_thi").val(html);
                $("#data_src").val('');
                $("#msg").html(data.message);
                ++count;
            }else{
                $("#msg").html(data.message);
            }              
        }  
        
        function postInfo() {
//            alert('sssss');
            var message = '';
            var code = document.getElementById('id_fb_thi_sinh');
            var name = document.getElementById('ten_thi_sinh');
            var email = document.getElementById('email');
            var image = document.getElementById('hinh_du_thi');
        
            if(message == '' && code.value ==''){
                message = 'Bạn chưa nhập mã thí sinh';
            }
            
            if(message == '' && name.value ==''){
                message = 'Bạn chưa nhập tên';
            } 
        
            if(message == '' && email.value ==''){
                message = 'Bạn chưa nhập email';
            }
            /*
            if(message == '' && image.value ==''){
                message = 'Bạn chưa có hình dự thi nào';
            }        
    		*/
            if(message != ''){
                message = source2.replace('[content]',message);
                modalPopup(align, top, width, padding, disableColor, disableOpacity, backgroundColor, borderColor, borderWeight, borderRadius, fadeOutTime, message, loadingImage);
            }else{
                document.f1.submit();
            }
            return false;        
        }
    
        new Picker.Date('ngay_sinh', {			
            pickerClass: 'datepicker_vista'			
        });	
    
    </script>


</center>